package com.example.database;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class MyChatContentDatabaseHelper extends SQLiteOpenHelper {

	private final static String DATABASE_NAME = "chat.db";
	private final static int VERSION = 1;
	
	public MyChatContentDatabaseHelper(Context context) {
		this(context,DATABASE_NAME,null,VERSION);
	}
	
	public MyChatContentDatabaseHelper(Context context, String name,
			CursorFactory factory, int version) {
		super(context, name, factory, version);
		
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		String sql_createString = "CREATE TABLE chat ( " +
						    "_id        INTEGER         PRIMARY KEY AUTOINCREMENT," +
						    "qq_number VARCHAR( 15 )   NOT NULL," +
						    "name      VARCHAR( 50 )   NOT NULL," +
						    "msg_type  INTEGER         NOT NULL" +
						    "                          DEFAULT ( 0 )," +
						    "text      VARCHAR( 512 )," +
						    "emoji     INTEGER         DEFAULT ( 0 ), " +
						    "isfrom    INTEGER         NOT NULL " +
						    "                          DEFAULT ( 1 ) " +
						");";
		db.execSQL(sql_createString);
		
		db.execSQL("insert into chat ('_id','qq_number','name','text','isfrom') values(1,'123456789','zhangsan','i like you',1);");
		db.execSQL("insert into chat ('_id','qq_number','name','text','isfrom') values(2,'348638799','beyond','i do not think so',0);");
		db.execSQL("insert into chat ('_id','qq_number','name','text','isfrom') values(3,'123456789','zhangsan','about two years already',1);");
		db.execSQL("insert into chat ('_id','qq_number','name','text','isfrom') values(4,'348638799','beyond','really?',0);");
		
//		ContentValues values = new ContentValues();
//		values.put("qq_number", "348638799");
//		values.put("name", "beyond");
//		values.put("text", "wobhhaoxxxx");
//		values.put("isfrom", 0);
//		
//		db.insert("chat", null, values);
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub

	}

}
